<?php
	//导入配置文件
	include("./config.php");

	//定义类
	class Model
	{
		//成员属性
		protected $tableName;
		protected $link;
		protected $pk;
		protected $fields = array();
		//存储字段信息
		protected $field;
		//存储排序信息
		protected $order;
		//存储条件信息
		protected $where;
		//存储limit信息
		protected $limit;


		//构造方法
		public function __construct($tableName)
		{
			$this->tableName = $tableName;
			//连接数据库
			$this->link = mysqli_connect(HOST,USER,PASS);
			//选择数据库
			mysqli_select_db($this->link,DBNAME);
			//设置字符集
			mysqli_set_charset($this->link,CHARSET);
			//获取有效字段
			$this->getfield();
		}
			/*
			*	获取有效字段	
			*/

			/*public function getfield()
			{
				//准备sql语句
				$sql = "desc ".$this->tableName;
				//执行
				$result = mysqli_query($this->link,$sql);
				var_dump($result);
				exit;
				if($result)
				{
					//遍历数据
					while($row = mysqli_fetch_assoc($result))
					{
						//判断
						if($row['Key'] == 'PRI')
						{
							//获取id
							$this->pk = $row['Field']
						}else{
							//获取数据表里有效字段
							$this->fields = $row['Field'];
						}
					}
				}
			}*/

			public function insert($arr)
			{
				//遍历数组


			}
		
	}


	//实例化对象
	$model = new Model('user');
	// $arr = array('username'=>'asdads','password'=>'asdasd','age'=>'23');

	//添加数据
